#define _SCL_SECURE_NO_WARNINGS
#include "Utility.h"



boost::multi_array<Cell, 2> * Utility::padMultiArray(boost::multi_array<Cell, 2> *grid, int width, int height){

	boost::multi_array<Cell, 2> * outGrid = new boost::multi_array<Cell, 2>;
	outGrid->resize(boost::extents[width][height]);

	for(int i = 0; i < width; i++)
	{
		for(int j = 0; j < height; j++)
		{
			(*outGrid)[i][j] = (*grid)[i][j];

			if((*grid)[i][j].difficulty >= 1){

				if(i > 0){
					(*outGrid)[i-1][j].difficulty = 1;
					(*outGrid)[i-1][j].closed = true;
				}

				if(i > 0 && j > 0){
					(*outGrid)[i-1][j-1].difficulty = 1;
					(*outGrid)[i-1][j-1].closed = true;
				}

				if(i > 0 && j < height - 1){
					(*outGrid)[i-1][j+1].difficulty = 1;
					(*outGrid)[i-1][j+1].closed = true;
				}
				
				if(j > 0){
					(*outGrid)[i][j-1].difficulty = 1;
					(*outGrid)[i][j-1].closed = true;
				}

				if(j < height - 1){
					(*outGrid)[i][j+1].difficulty = 1;
					(*outGrid)[i][j+1].closed = true;
				}

				if(i < width - 1 && j > 0){
					(*outGrid)[i+1][j-1].difficulty = 1;
					(*outGrid)[i+1][j-1].closed = true;
				}

				if(i < width - 1){
					(*outGrid)[i+1][j].difficulty = 1;
					(*outGrid)[i+1][j].closed = true;
				}

				if(i < width - 1 && j < height - 1){
					(*outGrid)[i+1][j+1].difficulty = 1;
					(*outGrid)[i+1][j+1].closed = true;

				}
			}		
		}
	}

	return outGrid;


}

